

package com.hazelcast.client.test.ifunction;

import com.hazelcast.client.test.IdentifiedFactory;
import com.hazelcast.core.IFunction;
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.nio.serialization.IdentifiedDataSerializable;

import java.io.IOException;

public class AppendString implements IFunction<String, String>, IdentifiedDataSerializable {
    public static final int CLASS_ID = 17;
    private String suffix;

    @Override
    public String apply(String input) {
        return input + suffix;
    }

    @Override
    public int getFactoryId() {
        return IdentifiedFactory.FACTORY_ID;
    }

    @Override
    public int getClassId() {
        return CLASS_ID;
    }

    @Override
    public void writeData(ObjectDataOutput out) throws IOException {
        out.writeString(suffix);
    }

    @Override
    public void readData(ObjectDataInput in) throws IOException {
        suffix = in.readString();
    }
}
